<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * UUID.js: The RFC-compliant UUID generator for JavaScript.
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * @fileOverview
<span class='line'>  5</span>  * @author  LiosK
<span class='line'>  6</span>  * @version 3.2
<span class='line'>  7</span>  * @license The MIT License: Copyright (c) 2010-2012 LiosK.
<span class='line'>  8</span>  */</span><span class="WHIT">
<span class='line'>  9</span> 
<span class='line'> 10</span> </span><span class="COMM">/** @constructor */</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">UUID</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 12</span> 
<span class='line'> 13</span> </span><span class="NAME">UUID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">overwrittenUUID</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 14</span> 
<span class='line'> 15</span> </span><span class="COMM">// Core Component {{{</span><span class="WHIT">
<span class='line'> 16</span> 
<span class='line'> 17</span> </span><span class="COMM">/** @lends UUID */</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">UUID</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 19</span> 
<span class='line'> 20</span> </span><span class="COMM">/**
<span class='line'> 21</span>  * The simplest function to get an UUID string.
<span class='line'> 22</span>  * @returns {string} A version 4 UUID string.
<span class='line'> 23</span>  */</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="NAME">UUID.generate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._getRandomInt</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._hexAligner</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT">  </span><span class="NAME">hex</span><span class="PUNC">(</span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="WHIT">          </span><span class="COMM">// time_low</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">(</span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT">          </span><span class="COMM">// time_mid</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">(</span><span class="NUMB">0x4000</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">12</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// time_hi_and_version</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">(</span><span class="NUMB">0x8000</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">14</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// clock_seq_hi_and_reserved clock_seq_low</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">        </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">(</span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">48</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">        </span><span class="COMM">// node</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 36</span> 
<span class='line'> 37</span> </span><span class="COMM">/**
<span class='line'> 38</span>  * Returns an unsigned x-bit random integer.
<span class='line'> 39</span>  * @param {int} x A positive integer ranging from 0 to 53, inclusive.
<span class='line'> 40</span>  * @returns {int} An unsigned x-bit random integer (0 &lt;= f(x) &lt; 2^x).
<span class='line'> 41</span>  */</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="NAME">UUID._getRandomInt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT">   </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">NaN</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">30</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">Math.random</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT">      </span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">53</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">Math.random</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT">     </span><span class="NUMB">30</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">                    </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">Math.random</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">30</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">30</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">NaN</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> 
<span class='line'> 50</span> </span><span class="COMM">/**
<span class='line'> 51</span>  * Returns a function that converts an integer to a zero-filled string.
<span class='line'> 52</span>  * @param {int} radix
<span class='line'> 53</span>  * @returns {function(num&#44; length)}
<span class='line'> 54</span>  */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="NAME">UUID._getIntAligner</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">radix</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">num</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">num.toString</span><span class="PUNC">(</span><span class="NAME">radix</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">str.length</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">z</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">>>></span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">z</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">z</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">z</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> 
<span class='line'> 63</span> </span><span class="NAME">UUID._hexAligner</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._getIntAligner</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="COMM">// }}}</span><span class="WHIT">
<span class='line'> 66</span> 
<span class='line'> 67</span> </span><span class="COMM">// UUID Object Component {{{</span><span class="WHIT">
<span class='line'> 68</span> 
<span class='line'> 69</span> </span><span class="COMM">/**
<span class='line'> 70</span>  * Names of each UUID field.
<span class='line'> 71</span>  * @type string[]
<span class='line'> 72</span>  * @constant
<span class='line'> 73</span>  * @since 3.0
<span class='line'> 74</span>  */</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="NAME">UUID.FIELD_NAMES</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"timeLow"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"timeMid"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"timeHiAndVersion"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">                    </span><span class="STRN">"clockSeqHiAndReserved"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"clockSeqLow"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"node"</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> 
<span class='line'> 78</span> </span><span class="COMM">/**
<span class='line'> 79</span>  * Sizes of each UUID field.
<span class='line'> 80</span>  * @type int[]
<span class='line'> 81</span>  * @constant
<span class='line'> 82</span>  * @since 3.0
<span class='line'> 83</span>  */</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="NAME">UUID.FIELD_SIZES</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> 
<span class='line'> 86</span> </span><span class="COMM">/**
<span class='line'> 87</span>  * Generates a version 4 {@link UUID}.
<span class='line'> 88</span>  * @returns {UUID} A version 4 {@link UUID} object.
<span class='line'> 89</span>  * @since 3.0
<span class='line'> 90</span>  */</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="NAME">UUID.genV4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._getRandomInt</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">UUID</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">_init</span><span class="PUNC">(</span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// time_low time_mid</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">                          </span><span class="NUMB">0x4000</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">12</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="COMM">// time_hi_and_version</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">                          </span><span class="NUMB">0x80</span><span class="WHIT">   </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">6</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">   </span><span class="COMM">// clock_seq_hi_and_reserved</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">                          </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">8</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">48</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// clock_seq_low node</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> 
<span class='line'> 99</span> </span><span class="COMM">/**
<span class='line'>100</span>  * Converts hexadecimal UUID string to an {@link UUID} object.
<span class='line'>101</span>  * @param {string} strId UUID hexadecimal string representation ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").
<span class='line'>102</span>  * @returns {UUID} {@link UUID} object or null.
<span class='line'>103</span>  * @since 3.0
<span class='line'>104</span>  */</span><span class="WHIT">
<span class='line'>105</span> </span><span class="NAME">UUID.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">strId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p.exec</span><span class="PUNC">(</span><span class="NAME">strId</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">8</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">        </span><span class="PUNC">(</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"{"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">        </span><span class="PUNC">(</span><span class="NAME">l.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"urn:uuid:"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">UUID</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">_init</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">                              </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">4</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">5</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">                              </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">6</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">[</span><span class="NUMB">7</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> 
<span class='line'>120</span> </span><span class="COMM">/**
<span class='line'>121</span>  * Initializes {@link UUID} object.
<span class='line'>122</span>  * @param {uint32} [timeLow=0] time_low field (octet 0-3).
<span class='line'>123</span>  * @param {uint16} [timeMid=0] time_mid field (octet 4-5).
<span class='line'>124</span>  * @param {uint16} [timeHiAndVersion=0] time_hi_and_version field (octet 6-7).
<span class='line'>125</span>  * @param {uint8} [clockSeqHiAndReserved=0] clock_seq_hi_and_reserved field (octet 8).
<span class='line'>126</span>  * @param {uint8} [clockSeqLow=0] clock_seq_low field (octet 9).
<span class='line'>127</span>  * @param {uint48} [node=0] node field (octet 10-15).
<span class='line'>128</span>  * @returns {UUID} this.
<span class='line'>129</span>  */</span><span class="WHIT">
<span class='line'>130</span> </span><span class="NAME">UUID.prototype._init</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">names</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID.FIELD_NAMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sizes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID.FIELD_SIZES</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._binAligner</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._hexAligner</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> 
<span class='line'>134</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>135</span>    * List of UUID field values (as integer values).
<span class='line'>136</span>    * @type int[]
<span class='line'>137</span>    */</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">  </span><span class="NAME">this.intFields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NUMB">6</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> 
<span class='line'>140</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>141</span>    * List of UUID field values (as binary bit string values).
<span class='line'>142</span>    * @type string[]
<span class='line'>143</span>    */</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">  </span><span class="NAME">this.bitFields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NUMB">6</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> 
<span class='line'>146</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>147</span>    * List of UUID field values (as hexadecimal string values).
<span class='line'>148</span>    * @type string[]
<span class='line'>149</span>    */</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">  </span><span class="NAME">this.hexFields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NUMB">6</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> 
<span class='line'>152</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">intValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">    </span><span class="NAME">this.intFields</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.intFields</span><span class="PUNC">[</span><span class="NAME">names</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">intValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    </span><span class="NAME">this.bitFields</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bitFields</span><span class="PUNC">[</span><span class="NAME">names</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bin</span><span class="PUNC">(</span><span class="NAME">intValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sizes</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">    </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NAME">names</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">(</span><span class="NAME">intValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sizes</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>158</span> 
<span class='line'>159</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>160</span>    * UUID version number defined in RFC 4122.
<span class='line'>161</span>    * @type int
<span class='line'>162</span>    */</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">  </span><span class="NAME">this.version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.intFields.timeHiAndVersion</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">12</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> 
<span class='line'>165</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>166</span>    * 128-bit binary bit string representation.
<span class='line'>167</span>    * @type string
<span class='line'>168</span>    */</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">  </span><span class="NAME">this.bitString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bitFields.join</span><span class="PUNC">(</span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> 
<span class='line'>171</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>172</span>    * UUID hexadecimal string representation ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").
<span class='line'>173</span>    * @type string
<span class='line'>174</span>    */</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">  </span><span class="NAME">this.hexString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">                 </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NUMB">4</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.hexFields</span><span class="PUNC">[</span><span class="NUMB">5</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>177</span> 
<span class='line'>178</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>179</span>    * UUID string representation as a URN ("urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").
<span class='line'>180</span>    * @type string
<span class='line'>181</span>    */</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">  </span><span class="NAME">this.urn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"urn:uuid:"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.hexString</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> 
<span class='line'>184</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> 
<span class='line'>187</span> </span><span class="NAME">UUID._binAligner</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._getIntAligner</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> 
<span class='line'>189</span> </span><span class="COMM">/**
<span class='line'>190</span>  * Returns UUID string representation.
<span class='line'>191</span>  * @returns {string} {@link UUID#hexString}.
<span class='line'>192</span>  */</span><span class="WHIT">
<span class='line'>193</span> </span><span class="NAME">UUID.prototype.toString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hexString</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>194</span> 
<span class='line'>195</span> </span><span class="COMM">/**
<span class='line'>196</span>  * Tests if two {@link UUID} objects are equal.
<span class='line'>197</span>  * @param {UUID} uuid
<span class='line'>198</span>  * @returns {bool} True if two {@link UUID} objects are equal.
<span class='line'>199</span>  */</span><span class="WHIT">
<span class='line'>200</span> </span><span class="NAME">UUID.prototype.equals</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">uuid</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">uuid</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">UUID</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.intFields</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">uuid.intFields</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>207</span> 
<span class='line'>208</span> </span><span class="COMM">// }}}</span><span class="WHIT">
<span class='line'>209</span> 
<span class='line'>210</span> </span><span class="COMM">// UUID Version 1 Component {{{</span><span class="WHIT">
<span class='line'>211</span> 
<span class='line'>212</span> </span><span class="COMM">/**
<span class='line'>213</span>  * Generates a version 1 {@link UUID}.
<span class='line'>214</span>  * @returns {UUID} A version 1 {@link UUID} object.
<span class='line'>215</span>  * @since 3.0
<span class='line'>216</span>  */</span><span class="WHIT">
<span class='line'>217</span> </span><span class="NAME">UUID.genV1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">now</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">st</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._state</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">now</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">st.timestamp</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">now</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">st.timestamp</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">st.sequence</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">    </span><span class="NAME">st.timestamp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">now</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">    </span><span class="NAME">st.tick</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._getRandomInt</span><span class="PUNC">(</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Math.random</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">UUID._tsRatio</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">st.tick</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">9984</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">    </span><span class="COMM">// advance the timestamp fraction at a probability</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">    </span><span class="COMM">// to compensate for the low timestamp resolution</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">    </span><span class="NAME">st.tick</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">UUID._getRandomInt</span><span class="PUNC">(</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">    </span><span class="NAME">st.sequence</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>230</span> 
<span class='line'>231</span> </span><span class="WHIT">  </span><span class="COMM">// format time fields</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._getTimeFieldValues</span><span class="PUNC">(</span><span class="NAME">st.timestamp</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tf.low</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">st.tick</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">thav</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tf.hi</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NUMB">0x1000</span><span class="PUNC">;</span><span class="WHIT">  </span><span class="COMM">// set version '0001'</span><span class="WHIT">
<span class='line'>235</span> 
<span class='line'>236</span> </span><span class="WHIT">  </span><span class="COMM">// format clock sequence</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">  </span><span class="NAME">st.sequence</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0x3FFF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cshar</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">st.sequence</span><span class="WHIT"> </span><span class="PUNC">>>></span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NUMB">0x80</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// set variant '10'</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">csl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">st.sequence</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>240</span> 
<span class='line'>241</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">UUID</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">_init</span><span class="PUNC">(</span><span class="NAME">tl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tf.mid</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">thav</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cshar</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">csl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">st.node</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> 
<span class='line'>244</span> </span><span class="COMM">/**
<span class='line'>245</span>  * Re-initializes version 1 UUID state.
<span class='line'>246</span>  * @since 3.0
<span class='line'>247</span>  */</span><span class="WHIT">
<span class='line'>248</span> </span><span class="NAME">UUID.resetState</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">  </span><span class="NAME">UUID._state</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">UUID._state.constructor</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>251</span> 
<span class='line'>252</span> </span><span class="COMM">/**
<span class='line'>253</span>  * Probability to advance the timestamp fraction: the ratio of tick movements to sequence increments.
<span class='line'>254</span>  * @type float
<span class='line'>255</span>  */</span><span class="WHIT">
<span class='line'>256</span> </span><span class="NAME">UUID._tsRatio</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> 
<span class='line'>258</span> </span><span class="COMM">/**
<span class='line'>259</span>  * Persistent state for UUID version 1.
<span class='line'>260</span>  * @type UUIDState
<span class='line'>261</span>  */</span><span class="WHIT">
<span class='line'>262</span> </span><span class="NAME">UUID._state</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">UUIDState</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID._getRandomInt</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">  </span><span class="NAME">this.timestamp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">  </span><span class="NAME">this.sequence</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">14</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">  </span><span class="NAME">this.node</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">0x10000000000</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">40</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// set multicast bit '1'</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">  </span><span class="NAME">this.tick</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rand</span><span class="PUNC">(</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">  </span><span class="COMM">// timestamp fraction smaller than a millisecond</span><span class="WHIT">
<span class='line'>268</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>269</span> 
<span class='line'>270</span> </span><span class="COMM">/**
<span class='line'>271</span>  * @param {Date|int} time ECMAScript Date Object or milliseconds from 1970-01-01.
<span class='line'>272</span>  * @returns {object}
<span class='line'>273</span>  */</span><span class="WHIT">
<span class='line'>274</span> </span><span class="NAME">UUID._getTimeFieldValues</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">time</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">time</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">Date.UTC</span><span class="PUNC">(</span><span class="NUMB">1582</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">15</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">ts</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">0x100000000</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">10000</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFFFFF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT">  </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">low</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">ts</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFFFFF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">10000</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">0x100000000</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">            </span><span class="NAME">mid</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hm</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hi</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hm</span><span class="WHIT"> </span><span class="PUNC">>>></span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">timestamp</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">ts</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>279</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>280</span> 
<span class='line'>281</span> </span><span class="COMM">// }}}</span><span class="WHIT">
<span class='line'>282</span> 
<span class='line'>283</span> </span><span class="COMM">// Misc. Component {{{</span><span class="WHIT">
<span class='line'>284</span> 
<span class='line'>285</span> </span><span class="COMM">/**
<span class='line'>286</span>  * Reinstalls {@link UUID.generate} method to emulate the interface of UUID.js version 2.x.
<span class='line'>287</span>  * @since 3.1
<span class='line'>288</span>  * @deprecated Version 2.x. compatible interface is not recommended.
<span class='line'>289</span>  */</span><span class="WHIT">
<span class='line'>290</span> </span><span class="NAME">UUID.makeBackwardCompatible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">UUID.generate</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">  </span><span class="NAME">UUID.generate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">o.version</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">UUID.genV1</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">hexString</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">f.call</span><span class="PUNC">(</span><span class="NAME">UUID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">  </span><span class="NAME">UUID.makeBackwardCompatible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> 
<span class='line'>298</span> </span><span class="COMM">/**
<span class='line'>299</span>  * Preserves the value of 'UUID' global variable set before the load of UUID.js.
<span class='line'>300</span>  * @since 3.2
<span class='line'>301</span>  * @type object
<span class='line'>302</span>  */</span><span class="WHIT">
<span class='line'>303</span> </span><span class="NAME">UUID.overwrittenUUID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">overwrittenUUID</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>304</span> 
<span class='line'>305</span> </span><span class="COMM">// }}}</span><span class="WHIT">
<span class='line'>306</span> 
<span class='line'>307</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">UUID</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> 
<span class='line'>309</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="NAME">UUID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>310</span> 
<span class='line'>311</span> </span><span class="COMM">// vim: et ts=2 sw=2 fdm=marker fmr&</span><span class="WHIT">
<span class='line'>312</span> </span></pre></body></html>